package baseFx.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;

public class InputStreamWrapper extends InputStream {
    private InputStream is;

    public InputStreamWrapper(InputStream stream) {
        this.is = stream;
    }

    @Override
    public int read() throws IOException {
        return is.read();
    }

    @Override
    public long skip(long n) throws IOException {
        return is.skip(n);
    }

    @Override
    public void close() throws IOException {
        is.close();
    }

    @Override
    public int available() throws IOException {
        return is.available();
    }

    @Override
    public synchronized void mark(int readlimit) {
        is.mark(readlimit);
    }

    @Override
    public boolean markSupported() {
        return is.markSupported();
    }

    @Override
    public synchronized void reset() throws IOException {
        is.reset();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        InputStreamWrapper that = (InputStreamWrapper) o;

        if (!Objects.equals(is, that.is)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        return is != null ? is.hashCode() : 0;
    }
}
